<!-- header area start here -->
<header id="headerDiv">
    <div class="header_top_area">
        <div class="container">
            <div class="row">
                <div class="col-12 col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="contact_wrapper_top" style="float: right;">
                        <ul class="header_top_contact">
                            <li>
                                <div class="book-btn" v-if="show">
                                    <a href="/hotel/registerHotel">成为商家</a>
                                </div>
                                <div class="book-btn" v-if="!show">
                                    <a href="/hotel/hotelManage">我的酒店</a>
                                </div>
                            </li>
                            <li>
                                <div class="book-btn">
                                    <a href="/hotel/myOrder">我的订单</a>
                                </div>
                            </li>
                            <li>
                                <div class="book-btn">
                                    <a href="/tourism/routeAdd">添加新路线</a>
                                </div>
                            </li>
                            <li th:if="${session.user} == null">
                                <div class="book-btn">
                                    <a href="/tourism/login">登录</a>
                                </div>
                            </li>
                            <li th:if="${session.user} != null">
                                <div class="book-btn">
                                    <a href="#" onclick="logout()">登出</a>
                                </div>
                            </li>
                            <input type="hidden" id="user_id" th:value="${session.user.userId}">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- header top end -->

    <div class="main_nav">
        <div class="container">
            <div class="row">
                <div class="col-md-2 col-sm-2 col-xs-12 tap-v-responsive">
                    <div class="logo-area">
                        <a href="index.html"><img src="/reception/images/logo.png" alt="">
                        </a>
                    </div>
                </div>
                <div class="col-md-10">
                    <nav>
                        <ul class="main-menu text-right">
                            <li class="active">
                                <a href="/common/main">主页</a>
                            </li>
                            <li>
                                <a href="/tourism/route">旅游路线</a>
                            </li>
                            <li>
                                <a href="/hotel/hotels">酒店</a>
                            </li>
                        </ul>
                    </nav>
                </div> <!-- main menu end here -->
            </div>
        </div>
    </div> <!-- header-bottom area end here -->
</header>
<!-- header area end here -->
<script>
    var headerVue = new Vue({
        el: "#headerDiv",
        data: {
            show: true
        },
        methods: {
            initPage: function () {
                var self = this;
                var userId = $("#user_id").val();
                $.ajax({
                    url: "/api/hotelMain/" + userId,
                    type: "get",
                    success: function (rs) {
                        console.log(rs);
                        if (rs != null && rs !== "") {
                            self.show = false;
                        }
                    },
                    error: function (rs) {
                        layer.alert(rs.responseText, {icon: 0});
                    }
                })
            }
        },
        created: function () {

        },
        mounted: function () {
            this.initPage();
        }
    })

    function logout() {
        $.ajax({
            url: "/api/logout",
            type: "GET",
            success: function () {
                location.reload();
            }
        })
    }
</script>
